<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>node</title>
</head>
<body>
宏任务mac（慢）setTimeout 微任务mic（快）Promise.then 都是异步任务
<!--MutationObserver 微任务-->
<!--setImmediate 宏任务 只支持IE-->
<!--MessageChannel,Promise.then 微任务-->

<div id="app"></div>
<script>
  // setTimeout(()=>{
  //     console.log('timeout')
  // },0)
  // Promise.resolve().then(()=>{
  //     console.log('promise')
  // })
  //vm.$nextTick(()=>{}) 异步
  // let app =  document.getElementById('app');
  // let observer = new MutationObserver(()=>{
  //     console.log('节点已经更新');
  //     console.log(app.children.length)
  // });
  // observer.observe(app,{
  //     childList:true,
  // });
  // for (let i=0;i<20;i++){
  //     app.appendChild(document.createElement('p'))
  // }
  // for (let i=0;i<20;i++){
  //     app.appendChild(document.createElement('span'))
  // }

  let channel = new MessageChannel();
  channel.port1.postMessage('我爱你');

  channel.port2.onmessage=function (e) {
      console.log(e.data)
  }
  Promise.resolve().then(data=>{
      console.log('promise then')
  })
</script>
</body>
</html>
